//! \file UiConsole.c
//! \brief TODO: Document
// -----------------------------------------------------------------------------
//! This program is free software; you can redistribute it and/or
//! modify it under the terms of the GNU General Public License
//! as published by the Free Software Foundation; either version 2
//! of the License, or (at your option) any later version.
//!
//! This program is distributed in the hope that it will be useful,
//! but WITHOUT ANY WARRANTY; without even the implied warranty of
//! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//! GNU General Public License for more details.
//!
//! You should have received a copy of the GNU General Public License
//! along with this program; if not, write to the Free Software Foundation,
//! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// -----------------------------------------------------------------------------

#include "UiConsole.h"
//#include <agar/core.h>
//#include <agar/gui.h>

// =====[ Local Definitions ]===================================================

// =====[ Local DataTypes ]=====================================================

// =====[ Local Variables ]=====================================================
// static AG_Textbox *pTextBox;

// =====[ Local Functions ]=====================================================
static void _UI_ConsoleAppendLine(AG_Event *event);
static void _UI_ConsoleDoNothing(AG_Event *event);

// =====[ Private (Internal) Methods ]==========================================

// =====[ Local Implementation ]================================================


// =============================================================================
// Implement: UI_ConsoleNew
// -----------------------------------------------------------------------------
tERROR UI_ConsoleNew(AG_Widget *pParent)
{
//    // Validate our arguments. TOOD: ???
//
//    AG_Console *pConsole;
//    AG_Box *pBox;
//    AG_Button *pButton;
//    AG_Menu *pMenu;
//    AG_Toolbar *toolbar;
//    AG_MenuItem *item;
//
//  //  // Create the console window.
//  //  pWindow = AG_WindowNew(AG_WINDOW_PLAIN | AG_WINDOW_KEEPABOVE | AG_WINDOW_HMAXIMIZE);
//  //  AG_WindowSetPadding(pWindow, 0, 0, 0, 0);
//  //  AG_WindowSetGeometry(pWindow, 50, 350, 300, 300);
//
//  /*  toolbar = AG_ToolbarNew(pWindow, AG_TOOLBAR_HORIZ, 1, 0);
//    pMenu = AG_MenuNew(pWindow, 0);
//    item = AG_MenuNode(pMenu->root, "File", NULL);
//    {
//      AG_MenuToolbar(item, toolbar);
//      AG_MenuAction(item, "Load", NULL, _UI_ConsoleDoNothing, NULL);
//      AG_MenuAction(item, "Save", NULL, _UI_ConsoleDoNothing, NULL);
//      AG_MenuToolbar(item, NULL);
//    }*/
//
//    // Create the console widget.
//    pConsole = AG_ConsoleNew(pParent, AG_CONSOLE_EXPAND);
//
//    // Create the text box input widgets.
//    pBox = AG_BoxNewHoriz(pParent, AG_BOX_HFILL);
//    pTextBox = AG_TextboxNew(pBox, AG_TEXTBOX_STATIC|AG_TEXTBOX_HFILL, "Input: ");
//    AG_SetEvent(pTextBox, "textbox-return", _UI_ConsoleAppendLine, "%p", pConsole);
//    AG_WidgetFocus(pTextBox);
//    pButton = AG_ButtonNewFn(pBox, 0, "OK", _UI_ConsoleAppendLine, "%p", pConsole);
//    AG_WidgetSetFocusable(pButton, 0);
//
//    // Create the additional buttons.
//    pBox = AG_BoxNewHoriz(pParent, AG_BOX_HFILL|AG_BOX_HOMOGENOUS);
//    AG_ButtonNewFn(pBox, 0, "Junk", _UI_ConsoleDoNothing, "%p", pConsole);
//    AG_ButtonNewFn(pBox, 0, "Clear", _UI_ConsoleDoNothing, "%p", pConsole);
//    AG_ButtonNewFn(pBox, 0, "Sel.Font", _UI_ConsoleDoNothing, "%p", pConsole);
//    AG_ButtonNewFlag(pBox, AG_BUTTON_STICKY, "Debug", &pConsole->vBar->flags, AG_SCROLLBAR_TEXT);
//
//    // Finally, show the console window.
//  //  AG_WindowSetPosition(pWindow, AG_WINDOW_BC, 0);
//  //  AG_WindowShow(pWindow);
//    // TODO: error checking?
}


// =============================================================================
// FxName
// -----------------------------------------------------------------------------
//! TODO: document
//!
//! \param [in] Arg
//!   TODO: document
//!
//! \retval Exception
//!   The success status of the requested operation.
//!   - eOKAY: Execution occurred as requested.
//!   .
//!
//! \b Example: \code
//! FxName(0);
//! \endcode
// -----------------------------------------------------------------------------
static void _UI_ConsoleAppendLine(AG_Event *event)
{
//  AG_Console *pConsole = AG_PTR(1);
//  char *pText;
//
//  pText = AG_TextboxDupString(pTextBox);
//  AG_ConsoleMsgS(pConsole, pText);
//  AG_TextboxSetString(pTextBox, "");
//  free(pText);
}


// =============================================================================
// FxName
// -----------------------------------------------------------------------------
//! TODO: document
//!
//! \param [in] Arg
//!   TODO: document
//!
//! \retval Exception
//!   The success status of the requested operation.
//!   - eOKAY: Execution occurred as requested.
//!   .
//!
//! \b Example: \code
//! FxName(0);
//! \endcode
// -----------------------------------------------------------------------------
static void _UI_ConsoleDoNothing(AG_Event *event)
{

}
